package com.sskj.b70.p.activity;

import com.lzy.okgo.model.Response;
import com.sskj.b70.m.HttpConfig;
import com.sskj.b70.m.bean.HttpData;
import com.sskj.b70.m.http.JsonCallBack;
import com.sskj.b70.p.base.BasePresenter;
import com.sskj.b70.utils.ToastUtil;
import com.sskj.b70.v.activity.VerifyIdentActivity;

import java.io.File;

/**
 * Created by Administrator on 2018/4/3 0003.
 */

public class VerifyIdentPresenter extends BasePresenter<VerifyIdentActivity> {
    //        public void submitVerify(String realName, String identNum, HashMap<String, Object> params) {
//        httpService.verifyIdentConfirm(realName, identNum, params)
//                .execute(new JsonCallBack<HttpData>(this) {
//                    @Override
//                    public void _onSuccess(Response<HttpData> response) {
//                        HttpData body = response.body();
//                        if (body.status == HttpConfig.STATUS_OK) {
//                            mView.onSubmitVerifyResponseSuccess();
//                        } else {
////                            mView.onSubmitVerifyResponseSuccess();
//                            ToastUtil.showShort(body.msg);
//                        }
//                    }
//                });
//    }
    public void checkIdent(String username, String idCardNo, String idCardFrontImg, String idCardBackImg, String selfieImg) {
        httpService.checkIdent(username, idCardNo, idCardFrontImg, idCardBackImg, selfieImg)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    protected void _onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.STATUS_OK) {
                            ToastUtil.showShort(httpData.getMsg());
                            mView.onSubmitVerifyResponseSuccess();
                        } else {
                            mView.onSubmitVerifyResponseSuccess();
                            ToastUtil.showShort(httpData.getMsg());
                        }
                    }
                });
    }

    public void uploadImg(File file) {
        httpService.uploadImg(file)
                .execute(new JsonCallBack<HttpData<String>>(this) {
                    @Override
                    protected void _onSuccess(Response<HttpData<String>> response) {
                        HttpData<String> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.STATUS_OK) {
                            mView.updatePath(httpData.getData());
                        }
                    }
                });
    }
}
